package coretest;

public class RegisterTest {
	private core.RegisterClass rb = null;
	public RegisterTest(){
		rb = new core.RegisterClass(16,15);
		for(int i = 0;i<rb.getMax(); i++){
			assert(this.rb.getRegister(i) == 0x000);
			this.rb.setRegister(i, (short)(i+2));
		}
		for(int i = 0;i<rb.getMax(); i++){
			assert(this.rb.getRegister(i) == (short)(i+2));
			this.rb.setRegister(i, (short)(i+2));
		}
		//System.out.printf("SP: <0x%04X>", this.rb.getSP());
		assert(this.rb.getSP() == 0x0011);
		this.rb.setSP((short)(this.rb.getSP() + 1));
		assert(this.rb.getSP() == 0x0012);
		this.rb.increaseSP();
		assert(this.rb.getSP() == 0x0013);
		this.rb.decreaseSP();
		assert(this.rb.getSP() == 0x0012);
		rb = new core.RegisterClass();
		assert(this.rb.getMax() == 16);
		
		rb = new core.RegisterClass(12);
		assert(this.rb.getMax() == 12);
		rb.increaseSP();
		assert(this.rb.getRegister(this.rb.getMax()-1) == 0x0001);
		assert(this.rb.getRegister(11) == this.rb.getSP());
		rb.setSP((short)0xFFFF);
		assert(this.rb.getSP()==(short)0xFFFF);
		rb.decreaseSP();
		assert(this.rb.getSP()==(short)0xFFFE);
		rb.decreaseSP();
		assert(this.rb.getSP()==(short)0xFFFD);
		rb.increaseSP();
		assert(this.rb.getSP()==(short)0xFFFE);
		

		System.out.println("Bank Registers (16) OK");
	}
	public static void main(String args[]){
		new RegisterTest();
	}
}
